define(function (require, exports, module) {

  require("mixins/global.mixins.js");
  var mCard = require('andrew/card/index.js')
  var toastr = require("third/toastr/index.js");
  var api = require('service/api.js');
  var urlHelper = require("../../src/tools/urlHelper.js");

  var searchdata = new Array();

  var pageVue = new Vue({
    data: {
      configGroup: {
        groupId: "",
        artId: ""
      },
      detail: {
        CUSTOMER_NAME: ""
      },
      levelOne: [],
      levelTwo: [],
      artInfo: []
    },
    mounted: function () {
      var result = this.loadLevel(0);
      this.levelOne = result;
    },
    methods: {
      save: function () {
        var _this = this;
        var data = this.configGroup;
        // delete data.id;
        console.log(data);
        $.ajax({
          type: 'POST',
          url: SAVE_CONFIG_DATA_URL,
          contentType: 'application/json',
          data: JSON.stringify(data),
          dataType: "json",
          success: function (result) {
            if (result.errno == 0) {
              toastr.success("新增分类保存成功");
              console.log(this.configGroup);
              _this.configGroup = result.data;
              _this.imgUrl = result.data.groupIcon.indexOf("http") > -1 ? result.data.groupIcon : VIEW_IMG_URL + result.data.groupIcon;
              console.log("chatwin===================", this.configGroup);
            }
            // alert(result);
          }
        });
      },
      onLoadLevelTwo(parentId) {
        this.levelTwo = [];
        var result = this.loadLevel(parentId);
        this.levelTwo = result;
      },
      loadLevel(parentId, selectdom) {
        var curPageVue = this;
        var data;
        $.ajax({
          type: 'POST',
          async: false,
          url: QUERY_CONFIG_BY_PARENT_ID + parentId,
          contentType: 'application/json',
          dataType: "json",
          success: function (result) {
            if (result.errno == 0) {
              data = result.data;
            }
          }
        });
        return data;
      },
      querySearchAsync(queryString, callback) {
        var list = [{}];
        console.log(queryString);
        $.ajax({
          type: 'POST',
          url: ARTICLE_URLS.ARTICLE_LIST_BY_NAME + queryString,
          contentType: 'application/json',
          dataType: "json",
          success: function (result) {
            if (result.errno == 0) {
              list = result.data; 
              searchdata = list;
              callback(list);
            }
          }
        });

        // //调用的后台接口
        // let url = 后台接口地址 + queryString;
        // //从后台获取到对象数组
        // axios.get(url).then((response) => {
        //   //在这里为这个数组中每一个对象加一个value字段, 因为autocomplete只识别value字段并在下拉列中显示
        //   for (let i of response.data) {
        //     i.value = i.想要展示的数据;  //将想要展示的数据作为value
        //   }
        //   list = response.data;
        //   callback(list);
        // }).catch((error) => {
        //   console.log(error);
        // });
      },

      handleSelect(item) {
        console.log(item);
        this.configGroup.artId = item.id;
      }

    }
  }).$mount('#app')
})
